package com.jiapu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiapu.entity.Event;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface EventMapper /*extends BaseMapper<Event> */{

    @Transactional
    @Update("insert into `event` (`people_id`,`people_name`,`date`,`type`,`des`,`id_del`) VALUES (#{people_id},#{people_name},#{date},#{type},#{des},0);")
    void save(Event event);

    @Select("select people_id,people_name,date,type,des from event where id_del=0")
    List<Event> findAll();

//error
    @Select("select * from event where people_name=#{people_name}  like #{people_name} and id_del=0")
    List<Event> search(String people_name);

    @Transactional
    @Update("update event set people_name=#{people_name},date=#{date},type=#{type},des=#{des} where people_id=#{people_id}")
    void updateById(Event event);

    @Transactional
    @Update("update event set id_del=1 where people_id=#{people_id}")
    void deleteById(Event event);
}
